import React from 'react';
import ModalForm from '../../../components/modalForm';

export default function Editor(props) {
    const { isNew, chargeType, sumUnit, timeUnit } = props;
    let config = {};
    if (!isNew) {
        config.id = {
            label: 'ID',
            input: {
                disabled: true,
            },
        };
    }
    const requiredRule = {
        required: true,
        message: '必填项',
    };
    config = {
        ...config,
        name: {
            label: '名称',
            fd: {
                rules: [requiredRule],
            },
        },
        chargeTypeId: {
            label: '模版类型',
            type: 'select',
            input: {
                data: chargeType,
                disabled: true,
            },
            fd: {
                initialValue: chargeType[0].id,
            },
        },
        timeUnitId: {
            label: '计时单位',
            type: 'select',
            input: {
                data: timeUnit,
            },
            fd: {
                initialValue: timeUnit[0].id,
            },
        },
        price: {
            label: '单价金额',
            type: 'number',
        },
        sumUnitId: {
            label: '金额单位',
            type: 'select',
            input: {
                data: sumUnit,
                disabled: true,
            },
            fd: {
                initialValue: sumUnit[0].id,
            },
        },
        atLeast: {
            label: '低消时长',
            type: 'number',
            fd: {
                initialValue: 10,
            },
        },
        personsCount: {
            label: '最多人数',
            type: 'number',
            fd: {
                initialValue: 1,
            },
        },
        status: {
            label: '状态',
            type: 'bool',
        },

    };

    return (
        <ModalForm
            {
                ...{
                    ...props,
                    config
                }
            }
        />
    );
}
